Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Clean up ExternalInterface a little #18223

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Dinnerbone
Copy link
Contributor

Instead of getting a method then calling it, we just call things directly now. We also can now only have one Provider instead of many, but realistically there's no case in which multiple providers can peacefully coexist as they'll be conflicting with methods.

@Dinnerbone Dinnerbone added A-core Area: Core player, where no other category fits T-refactor Type: Refactor / Cleanup labels Oct 9, 2024
for arg in &args[1..] {
external_args.push(ExternalValue::from_avm1(activation, arg.to_owned())?);
}
let mut external_args = Vec::with_capacity(external_args_len);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably write this using an iterator an map.

} else {
Ok(Value::Null)
let mut external_args = Vec::with_capacity(args.len() - 1);
for arg in &args[1..] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

}

pub fn available(&self) -> bool {
!self.providers.is_empty()
self.provider.is_some()
}

pub fn any_id(&self) -> Option<String> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could rename this to get_id now.

fn is_location_href(code: &str) -> bool {
matches!(
code,
"document.location.href" | "window.location.href" | "top.location.href"
)
}

struct FakeEval(Option<Url>);

impl ExternalInterfaceMethod for FakeEval {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core player, where no other category fits T-refactor Type: Refactor / Cleanup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants